<extend name="layout/main" />

<block name="HEADER">
	
</block>

<block name="CONTENT">
	<control:grid id="grid"/>
</block>

<block name="FOOTER">
	<script type="text/javascript">
		var page = (function(ns){
            
		    //页面初始化
		    ns.init=function(){
		      
		    }
		    
		    //新增
		    ns.add=function(){
		    	var filter = {
		            url: $.getModule('edit'),
		            mode:1
		        }
		        $.openIframe(filter, "新增",['1100px', '570px']);
		    }
		    
		    //编辑
		    ns.edit = function(){
		    	var selectedRow = grid.getSelectedRows()[0];
		    	if(!selectedRow){
		    	    $.toast(0,'请选择数据！');
		    	    return false;
		    	}
		        var filter = {
		            url: $.getModule('edit'),
		            oid: selectedRow[grid.option.key],
		            mode:2,
		            shop_id:selectedRow['shop_id']
		        }
		        $.openIframe(filter,"编辑",['1100px', '570px']);
		    }  
		    
		    //编辑
		    ns.details = function(){
		    	var selectedRow = grid.getSelectedRows()[0];
		    	if(!selectedRow){
		    	    $.toast(0,'请选择数据！');
		    	    return false;
		    	}
		        var filter = {
		            url: $.getModule('details'),
		            oid: selectedRow[grid.option.key],
		            mode:2,
		            shop_id:selectedRow['shop_id']
		        }
		        $.openIframe(filter,"员工详情",['800px', '570px']);
		    }  
		    
		    
		    //会员详情
		    ns.memberDetails =function(uid){
		        var filter = {
		            url:"/system/member/index/edit",
		            oid: uid,
		            mode:3
		        }
		        $.openIframe(filter, "会员详情",['800px', '92%']);
		    }  
		    
		    //删除
		    ns.del =function(){
		    	grid.deleteSelectRow(true);
		    }
		    
		    //离职
		    ns.quit =function(){
		    	var selectedRow = grid.getSelectedRows()[0];
		    	if(!selectedRow){
		    	    $.toast(0,'请选择数据！');
		    	    return false;
		    	}
		    	$.confirm("工号："+ selectedRow.gh+"确定离职?",function(index){
		    		grid.updateField(selectedRow.id,'status',0);
		    		layer.close(index);
		    	});
		    }
		    
		    //复职
		    ns.complex =function(){
		    	var selectedRow = grid.getSelectedRows()[0];
		    	if(!selectedRow){
		    	    $.toast(0,'请选择数据！');
		    	    return false;
		    	}
		    	$.confirm("工号："+ selectedRow.gh+"确定复职?",function(index){
		    		grid.updateField(selectedRow.id,'status',1);
		    		layer.close(index);
		    	});
		    }
		    
		    
		    //更新密码
		    ns.updatePwd=function(){
		    	var selectedRow = grid.getSelectedRows()[0], pwdForm;
		    	if(!selectedRow){
		    		$.toast(0,"请先选择用户！");
		    		return;
		    	}
		       function successFn(){
		    		pwdForm = layui.forms.render("updatePwdForm","/modules/shop/staff/config.xml",{
		    		    mode:2,
		    		    oid:selectedRow.id
		    		});
		    	}
		    	function yesFn(index){
		    		pwdForm.save(1).then(function(res){
		            	grid.load();
		            	layer.close(index);
		            });
		    	}
		    	var html="<div id='updatePwdForm'></div>";
		    	$.openModalDialog(html,"重置密码",successFn,yesFn,["400px","250px"])
		    }
		    
		    return ns;
		}({}));
		
		$(function(){ page.init();  });
	</script>
</block>